package cc.iteachyou.template.dom;

import cn.hutool.extra.expression.ExpressionEngine;
import cn.hutool.extra.expression.engine.spel.SpELEngine;
import lombok.Data;

import java.util.LinkedHashMap;
import java.util.Map;

@Data
public abstract class VirtualDOMNode {
    protected String id;
    protected String hash;
    protected String name;
    protected String content;
    protected Boolean isSingleTag = false;
    protected Boolean loopable = false;
    protected String loopItemKey;
    protected String loopArray;

    protected Boolean branchable = false;
    protected String branchData;

    protected ExpressionEngine engine = new SpELEngine();

    protected RendererVirtualDOMAttrContext context;

    @Data
    public class RendererVirtualDOMAttrContext {
        private VirtualDOMNode prevNode;
        private VirtualDOMNode node;
        private VirtualDOMNode nextNode;
        private VirtualDOMAttr attr;
        private StringBuilder html;
        private Map<String, Object> data = new LinkedHashMap<>();
    }
}
